package com.cjl.utils.thread;

import com.cjl.host.pojos.Host;
import lombok.extern.slf4j.Slf4j;

/**
 * @author cjl
 * @version v1.0
 * @description TODO
 * @createTime 2023/2/16 11:34
 */
@Slf4j
public class HostThreadUtil {

    static ThreadLocal<Host> hostThreadLocal = new ThreadLocal<>();
    /**
     * 设置线程内初始化实例对象
     * @param host
     */
    public static void set(Host host) {
        hostThreadLocal.set(host);
    }

    /**
     * 获取该线程内的实例化对象
     * @return
     */
    public static Host get() {
        return hostThreadLocal.get();
    }

    /**
     * 移除线程内的实例化对象
     */
    public  static void remove() {
        hostThreadLocal.remove();
        log.info("释放EaterThreadLocal。。。");
    }
}
